package projeto;

import java.io.File;
import java.util.ArrayList;
import java.util.Scanner;

public class FileReader {		
		
	private ArrayList<BabyName> names  = new ArrayList<BabyName>();
		
	public FileReader(){
	}
	
	public void openFile(String fileName) throws Exception{
		String line;
		String[] list;
		File file = new File(fileName);
		Scanner scanner = new Scanner(file);
		while (scanner.hasNext()) {
			line = scanner.nextLine();
			list = line.split(",");
			this.names.add(new BabyName(list[0], Integer.parseInt(list[1])));
		}
		scanner.close();
	}

	public ArrayList<BabyName> getNames() {
		return names;
	}	
}
